import { request } from './request'
import type { LoginParams, TokenResponse, UserInfo } from '@/types'

// 登录
export const login = (data: LoginParams) => {
  return request<TokenResponse>({
    url: '/admin/auth/login',
    method: 'post',
    data
  })
}

// 登出
export const logout = () => {
  return request({
    url: '/admin/auth/logout',
    method: 'post'
  })
}

// 获取当前用户信息
export const getProfile = () => {
  return request<UserInfo>({
    url: '/admin/auth/profile',
    method: 'get'
  })
}

// 刷新Token
export const refreshToken = (refreshToken: string) => {
  return request<TokenResponse>({
    url: '/admin/auth/refresh',
    method: 'post',
    data: { refresh_token: refreshToken }
  })
}

